import {Component} from "react";
import PropTypes from 'prop-types'
class Search extends Component {
   componentDidMount() {
       if(this.input){
           this.input.focus()
       }
   }

    // console.log(children)
    render(){
        const {value, onChange,children,onSubmit} = this.props
        return (
            <form action="" onSubmit = {onSubmit}>
                <input ref={(node)=> { this.input = node }} className='App-search' type="text" value={value} placeholder='请输入搜索内容' onChange={onChange}/>
                <button type='submit' className='App-searchBt'>{children}</button>
            </form>
        )
    }

}
Search.propTypes = {
    value: PropTypes.string.isRequired,
    onChange: PropTypes.func.isRequired,
    children: PropTypes.string.isRequired,
    onSubmit: PropTypes.func.isRequired
}
export default  Search